package com.bigdata.appliance.controller;

import com.bigdata.appliance.common.pojo.PageResult;
import com.bigdata.appliance.service.IGoodsService;
import com.bigdata.appliance.vo.req.*;
import com.bigdata.appliance.vo.resp.PageGoodsRespVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 * 商品表 前端控制器
 * </p>
 *
 * @author appliance-shop
 * @since 2023-12-24
 */
@RestController
@RequestMapping("/api")
@Api(value = "UserController", tags = {"商品接口"})
public class GoodsController {

    @Resource
    private IGoodsService iGoodsService;

    @PostMapping("/uniApp/goods/add")
    @ApiOperation(value = "添加商品接口")
    public void addGoods(@RequestBody @Valid AddGoodsReqVO vo) {
        iGoodsService.addGoods(vo);
    }

    @PostMapping("/uniApp/goods/edit")
    @ApiOperation(value = "修改商品接口")
    public void editGoods(@RequestBody @Valid EditGoodsReqVO vo) {
        iGoodsService.editGoods(vo);
    }

    @PostMapping("/uniApp/goods/status")
    @ApiOperation(value = "修改商品接口")
    public void editGoodsStatus(@RequestBody @Valid EditGoodsStatusReqVO vo) {
        iGoodsService.editGoods(vo);
    }

    @PostMapping("/uniApp/goods")
    @ApiOperation(value = "商品分页接口")
    public PageResult<PageGoodsRespVO> editGoods(@RequestBody @Valid PageGoodsReqVO vo) {
        return iGoodsService.pageGoods(vo);
    }
}
